<?php

namespace App\Transformers;

use App\Models\FsUserPhone;
use App\Models\User;
use League\Fractal\TransformerAbstract;

class FsUserPhoneTransformer extends TransformerAbstract
{

    protected $availableIncludes = ['user','fsUser'];

    public function __construct($model = '')
    {
        if(!empty($model)){
            $this->defaultIncludes = [$model];
        }
    }

    public function transform(FsUserPhone $user)
    {
        return [
            'id' => $user->id,
            'status' => $user->status,
            'user_id' => $user->user_id,
            'fs_user_id' => $user->fs_user_id,
            'created_at' => empty($user->created_at)?'':$user->created_at->toDateTimeString(),
            'updated_at' => empty($user->updated_at)?'':$user->updated_at->toDateTimeString(),
        ];
    }

    public function includeUser(FsUserPhone $user)
    {
        return $this->item($user->user, new UserTransformer());
    }

    public function includeFsUser(FsUserPhone $user)
    {
        return $this->item($user->fsUser, new FsUserTransformer());
    }


}